window.onload = function () {
    let button = document.getElementsByTagName('button')[0]
    let span = document.getElementsByTagName('span')[0]
    button.onclick = function () {
        let username = document.getElementById('username').value
        let password = document.getElementById('password').value
        let userRegData = {}
        let regNumber = /^[1]([3-9])[0-9]{9}$/;
        let regPassword = /^[0-9a-zA-Z]{4,16}$/
        if (regNumber.test(username) && regPassword.test(password)) {
            userRegData.name = username;
            userRegData.pwdMD5 = password;
            userRegData.gender = "male";

            Ajax.post('http://10.101.96.3:8000/reg', JSON.stringify(userRegData), (data) => {
                let data1 = JSON.parse(data);
                if (data1.code == 2) {
                    span.innerHTML = data1.msg
                };
                if (data1.code == 4) {
                    span.innerHTML = data1.msg
                };

            })

        } else {
            span.innerHTML = "格式不正确！！！请重新输入"

        }
    }

}